package com.torry.edss.integration.feign.eastmoney;

import com.torry.edss.integration.feign.eastmoney.response.EMStockDetailInfoResponse;
import feign.Headers;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author torry.wang
 */
@FeignClient(name = "eastMoneyWebFeignClient", url = "https://datacenter-web.eastmoney.com")
public interface EastMoneyWebFeignClient {
    /**
     * 获取大宗交易数据
     * @param date yyyy-MM-dd
     * @return GetBlockTradeListResult
     */
    @GetMapping("/api/data/v1/get?sortColumns=SECURITY_CODE&sortTypes=1&pageSize=99999&pageNumber=1&reportName=RPT_DATA_BLOCKTRADE&columns=TRADE_DATE,SECURITY_CODE,SECUCODE,SECURITY_NAME_ABBR,CHANGE_RATE,CLOSE_PRICE,DEAL_PRICE,PREMIUM_RATIO,DEAL_VOLUME,DEAL_AMT,TURNOVER_RATE,BUYER_NAME,SELLER_NAME,CHANGE_RATE_1DAYS,CHANGE_RATE_5DAYS,CHANGE_RATE_10DAYS,CHANGE_RATE_20DAYS,BUYER_CODE,SELLER_CODE&source=WEB&client=WEB&filter=(SECURITY_TYPE_WEB=\"1\")(TRADE_DATE='{date}')")
    @Headers({"Content-Type: application/json"})
    String getBlockTradesByDate(@PathVariable(name = "date") String date);

    @GetMapping("/api/data/v1/get?reportName=RPT_DAILYBILLBOARD_PROFILE&columns=ALL&pageNumber=1&pageSize=99999&sortTypes=1&sortColumns=SECURITY_CODE&source=WEB&client=WEB")
    @Headers({"Content-Type: application/json"})
    String getLastTradingDayLeaderboard();

    @GetMapping("/api/data/v1/get?sortColumns=SECURITY_CODE,TRADE_DATE&sortTypes=1,-1&pageSize=99999&pageNumber=1&reportName=RPT_DAILYBILLBOARD_DETAILSNEW" +
            "&columns=SECURITY_CODE,SECUCODE,SECURITY_NAME_ABBR,TRADE_DATE,CLOSE_PRICE,CHANGE_RATE,TURNOVERRATE" +
            "&source=WEB&client=WEB&filter=(TRADE_DATE<='{date}')(TRADE_DATE>='{date}')")
    @Headers({"Content-Type: application/json"})
   String getLeaderboardByDate(@PathVariable(name = "date") String date);

    @GetMapping("/api/data/v1/get?reportName={reportName}" +
            "&columns=ALL" +
            "&filter=(TRADE_DATE='{date}')(SECURITY_CODE=\"{code}\")" +
            "&pageNumber=1&pageSize=9999&sortTypes=-1&sortColumns={sortColumn}&source=WEB&client=WEB&_=1722921242656")
    String getLeaderboardDetails(@PathVariable(name = "reportName") String reportName,
                                 @PathVariable(name = "sortColumn") String sortColumn,
                                 @PathVariable(name = "code") String code,
                                 @PathVariable(name = "date") String date);


    @GetMapping("api/data/v1/get?" +
            "reportName=RPT_F10_ORG_BASICINFO" +
            "&columns=ALL" +
            "&sortColumns=" +
            "&sortTypes=" +
            "&source=WEB" +
            "&client=WEB" +
            "&filter=(SECURITY_CODE={code})")
    /**
     * 获取公司详细信息
     */
    EMStockDetailInfoResponse fetchStockDetailInfo(@PathVariable(name = "code") String code);
}
